<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="../css/bootstrap.css">
    <title>省份修改</title>
</head>
<body>
<div id="app">
    <div class="container">
        <div class="row">
            <div class="col-md-8 col-md-offset-2">
                <span> {{ message }} </span>
                <form>
                    <div class="form-group">
                        <label for="province">省份</label>
                        <input type="text" class="form-control" id="province" placeholder="请输入省份" v-model="province.name">
                    </div>
                    <div class="form-group">
                        <label for="tags">标签</label>
                        <input type="text" class="form-control" id="tags" placeholder="请输入标签" v-model="province.tags">
                    </div>

                    <button type="button" class="btn btn-success" @click="updateProvince">修改</button>
                </form>
            </div>
        </div>
    </div>
</div>
</body>
</html>
<script src="../js/vue.js"></script>
<script src="../js/axios.min.js"></script>
<script>
    var app = new Vue({
        el:"#app",
        data:{
            province:{},
            message:"",
            id:"",
        },
        methods:{
            updateProvince(){
                let _this = this;
                axios.post("http://localhost:9999/province/update?id="+_this.id,_this.province).then(function (response) {
                    if (response.data.flag){
                        location.href="provinceList.html";
                    }else{
                        _this.message = response.data.message;
                    }
                })
            }

        },
        created(){
            this.id = location.href.substring(location.href.indexOf("=")+1);
        }

    });
</script>